package com.flyduck.vueshop.system.remote.service.impl;

import com.flyduck.vueshop.system.remote.service.RemoteRoleService;
import com.flyduck.vueshop.system.entity.SysRole;
import com.flyduck.vueshop.system.manager.SysPermissionCacheManager;
import com.flyduck.vueshop.system.mapper.SysRoleMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * SysUserApiServiceImpl
 * </p>
 *
 * @author flyduck
 * @since 2024-07-09
 */
@Service
public class RemoteRoleServiceImpl implements RemoteRoleService {

    @Resource
    private SysRoleMapper sysRoleMapper;
    @Resource
    private SysPermissionCacheManager sysPermissionCacheManager;

    @Override
    public List<String> getRoleCodeListByUserId(Long userId) {
        List<SysRole> sysRoleList = sysRoleMapper.getRoleListByUserId(userId);
        List<String> roleCodeList = sysRoleList.stream()
                .map(SysRole::getCode)
                .collect(Collectors.toList());
        return roleCodeList;
    }
}
